package com.rp.common.exception.handler;

/**
 * 类说明:
 *
 * @author ****
 * @date 2020-11-24 17:54  新建
 */


import com.rp.common.result.ResultDTO;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 描述：
 *
 * @author caojing
 * @create 2019-01-27-17:12
 */
@Order(98)
@ControllerAdvice
public class NoPermissionException {

    @ResponseBody
    @ExceptionHandler(UnauthorizedException.class)
    public ResultDTO handleShiroException(Exception ex) {
        return ResultDTO.PERMISSION_NOT();
    }

    @ResponseBody
    @ExceptionHandler(AuthorizationException.class)
    public ResultDTO AuthorizationException(Exception ex) {
        return ResultDTO.PERMISSION_ERROR();
    }
}

